Skip to content

perf: Add DI container caching for faster CLI startup#1289

Open
CybotTM wants to merge 1 commit intophpDocumentor:mainfrom
CybotTM:perf/cli-container-cache
Open

perf: Add DI container caching for faster CLI startup#1289
CybotTM wants to merge 1 commit intophpDocumentor:mainfrom
CybotTM:perf/cli-container-cache

Conversation

@CybotTM
Copy link
Copy Markdown
Contributor

@CybotTM CybotTM commented Jan 22, 2026

Summary

Caches the compiled Symfony DI container to /tmp/guides-container-cache/ for faster CLI startup times.

Changes

  • ContainerFactory: Cache compiled container using PhpDumper
    • Generates unique cache key from vendor directory path
    • Stores compiled container as PHP class file
    • Automatic invalidation when container configuration changes
    • Graceful fallback when container has uncacheable parameters

Performance Impact

Container compilation is skipped on subsequent runs, reducing startup time. Most beneficial for development workflows with frequent CLI invocations.

See Performance Analysis Report for detailed benchmarks.


Related PRs

PR Description Status
#1287 Rendering caching layer Independent
#1288 RST parsing optimizations Independent
#1289 This PR - CLI container caching
#1291 Symfony 8 compatibility ✅ Merged
#1293 ProjectNode O(1) document lookup Independent

All PRs can be merged independently in any order.

@CybotTM CybotTM force-pushed the perf/cli-container-cache branch from e24f21a to 22ad429 Compare January 22, 2026 01:30
@CybotTM CybotTM marked this pull request as draft January 22, 2026 01:33
@CybotTM CybotTM force-pushed the perf/cli-container-cache branch from 22ad429 to 6fc45f3 Compare January 22, 2026 01:33
@CybotTM CybotTM force-pushed the perf/cli-container-cache branch from 6fc45f3 to 38b08dc Compare January 23, 2026 13:01
@CybotTM CybotTM marked this pull request as ready for review January 23, 2026 13:06
@CybotTM CybotTM force-pushed the perf/cli-container-cache branch from 38b08dc to cd5012c Compare March 9, 2026 00:21
Cache the compiled Symfony DI container to /tmp/guides-container-cache/.
On subsequent runs, loads pre-compiled PHP class instead of rebuilding
the entire container (config parsing, service registration, compilation).

Cache key includes vendor dir, working dir, extensions, and configs to
ensure cache invalidation when configuration changes.

See https://cybottm.github.io/render-guides/ for benchmark data.
@CybotTM CybotTM force-pushed the perf/cli-container-cache branch from cd5012c to 526e83a Compare April 16, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant